<?php
 include_once('config/config.php');
 // 获取id
 if(!$_GET){
	ShowMsg('请选择编辑的数据','departmentlist.php');
	exit;
 }
 // 
 $id = $_GET['id'];
 // 
 $sql = "SELECT * FROM pre_department WHERE id = '$id';";
 
 $result = find($sql);
 
 // 提交修改的数据
 if($_POST){
	// 修改
	$data = [
		'name' => $_POST['dep_name']
	];
	// 
	$res = update('department',$data,"id = '$id'");
	if($res){
		ShowMsg('修改成功！','departmentlist.php');
	}
 }
?>
<!DOCTYPE html>
<html lang="en">
	<head>
		<?php include_once('common/meta.php'); ?>
	</head>
	<style>
		
	</style>
	<body>
		<!--<![endif]-->

		<?php include_once('common/header.php'); ?>

		<?php include_once('common/sidebar.php'); ?>

		<div class="content">
			<div class="header">
				<h1 class="page-title">修改部门</h1>
			</div>
			<ul class="breadcrumb">
				<li><a href="index.php">Home</a> <span class="divider">/</span></li>
				<li class="active">Index</li>
			</ul>

			<div class="container-fluid">
				<div class="row-fluid">

					<div class="btn-toolbar">
						<button class="btn btn-primary" onClick="location='departmentlist.php'"><i class="icon-list"></i>职位部门</button>
						<div class="btn-group">
						</div>
					</div>
					
					<div class="well">
						<div id="myTabContent" class="tab-content">
							<div class="tab-pane active in" id="home">
								<form method="post" enctype="multipart/form-data">
									<!-- 职位名称 -->
									<label>职位名称</label>
									<input type="text" name="dep_name" class="input-xxlarge" value="<?php echo $result['name'] ?>" placeholder="请输入部门名称" required />
									
									<br />
									<!-- 提交 -->
									<button type="submit" class="btn btn-primary">提交</button>
								</form>
							</div>
						</div>
					</div>
					<?php include_once('common/footer.php'); ?>

				</div>
			</div>
		</div>

		<?php include_once('common/script.php'); ?>

	</body>
</html>
